/**
 * 一般移动的速度
 * @type {number}
 */
import {globalConfig} from "./globalConfig";

export let HERO_MOVE_SPEED = globalConfig.base_config.speed;
/**
 * 旋转的速度
 * @type {number}
 */
export let HERO_ROTATE_SPEED = globalConfig.base_config.rotate_speed;
/**
 * 加速时的速度
 * @type {number}
 */
export let ACCELERATE_SPEED = globalConfig.base_config.acc_speed;

/**
 * 击杀得分
 * @type {number}
 */
export let KILL_SCORE = 100;

/**
 * 圆球默认半径
 * @type {number}
 */
export let CIRCLE_DEFAULT_RADIUS = 15;

export let WEAPON_SCORE_MAPPING = {
  1: {
    width: 20,
    height: 80,
    score: 0
  },
  2: {
    width: 25,
    height: 120,
    score: 300
  },
  3: {
    width: 30,
    height: 170,
    score: 800
  },
  4: {
    width: 35,
    height: 230,
    score: 1500
  },
  5: {
    width: 40,
    height: 300,
    score: 2500
  },

}

export let INITIAL_ENERGY = 0;

export let ACC_ENERGY_CONSUME_RATE = 40;

/**
 * 旋转的CD时间，单位 m 秒
 * @type {number}
 */
export let ROTATE_COOL_DOWN = 5;

export const MAP_CONFIG: { mapid: number, startx: number, starty: number, row: number, height: number, column: number, width: number, bubblecount: number, playercount: number } = <any>globalConfig.map_config[0]

// export const BOUNDS = {
//     startX: 360,
//     startY: 300,
//     width: 3000,
//     height: 3000
// }

export const GAME_SECOND = 120;
export const BE_KILL_BOARD_COUNT = 3;

export const PORTAL_POINTS = [
  {x: 650, y: 700},
  {x: 1650, y: 700}
]

export const config = {
  baseConfig: {
    killScore: 100,
  },
  "sceneitem_config": [
    {
      gg: 1,
    }
  ]
}

// 1、钻石 2、金币 3、万能碎片 4、泳圈皮肤碎片 5、泳圈皮肤 6、头像 7、主题场景 8、礼包
export enum ResType {diamond = 1, gold, commonPiece, skinPiece, skin, head, theme, gift};
// 新手礼包、每日礼包id
export const NEWBIEGIFT = 8001;
export const DAILYGIFT = 8002;

// array转换成映射
export function configGetter(configkey: string, idkey: string) {
  let tmp = {};
  globalConfig[configkey].forEach(item => {
    tmp[item[idkey]] = item;
  });
  return (id: any, key?: string) => {
    return key ? tmp[id][key] : tmp[id];
  }
}

export let getItem = configGetter('item', 'id');
export let getReward = configGetter('rewardlist', 'id');
export let getGift = configGetter('novicepackage', 'id');

export function getItemName(id: number) {
  return getItem(id + '', 'name')
}